import org.apache.log4j.Logger;

public class InvokeTimer {
    private static Logger logger = Logger.getLogger(InvokeTimer.class);


    static ThreadLocal<Long> threadLocal = new ThreadLocal<Long>();


    public static void start() {
        threadLocal.set(System.currentTimeMillis());
    }

    public static void end() {
        long time = System.currentTimeMillis() - threadLocal.get();
        StackTraceElement element = Thread.currentThread().getStackTrace()[2];
        logger.debug("Class name:"+element.getClassName() +",Method name:"+ element.getMethodName() + ",Line number:"+ element.getLineNumber()+ ",耗费时间:" + time + "ms.");
    }
}